import 'package:auto_route/auto_route.dart';
import 'package:casdon/app/config/theme/theme_extention.dart';
import 'package:casdon/common/widget/conform_dialog.dart';
import 'package:casdon/app/config/env/common_config.dart';
import 'package:casdon/auto_router.dart';
import 'package:flutter/material.dart';
import 'package:flutter/gestures.dart';

/// 绑定手机号确认弹窗（多处复用）
Future<bool?> showBindPhoneConfirmDialog(BuildContext context) {
  return showCustomConfirmDialog(
    context: context,
    content: "绑定手机号，可同步已联网设备到该新账号内",
  );
}

/// 服务协议与隐私保护弹窗（多处复用）
Future<bool?> showAgreementDialog(BuildContext context) {
  return showCustomConfirmDialog(
    context: context,
    title: '服务协议及隐私保护',
    cancelText: '我在想想',
    confirmText: '同意',
    contentWidget: RichText(
      textAlign: TextAlign.center,
      text: TextSpan(
        style: Theme.of(context).textTheme.bodyMedium?.copyWith(
          color: context.customColorThemeNonNull.textColor2,
        ),
        children: [
          const TextSpan(text: '为保护您的合法权益，请先阅读并同意以下协议'),
          TextSpan(
            text: '《用户协议》',
            style: TextStyle(color: Theme.of(context).colorScheme.primary),
            recognizer: TapGestureRecognizer()
              ..onTap = () {
                context.router.push(
                  WebPageRoute(
                    url: CommonConfig.urser_protocol,
                    title: '《用户协议》',
                  ),
                );
              },
          ),
          const TextSpan(text: '和'),
          TextSpan(
            text: '《隐私政策》',
            style: TextStyle(color: Theme.of(context).colorScheme.primary),
            recognizer: TapGestureRecognizer()
              ..onTap = () {
                context.router.push(
                  WebPageRoute(
                    url: CommonConfig.privacy_protocol,
                    title: '《隐私政策》',
                  ),
                );
              },
          ),
        ],
      ),
    ),
    content: '',
  );
}
